﻿@model VisaApp.Models.SendMailModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestCategoeyChauLuc",
        OnBegin = "show_Loading",
    };
}

<script type="text/javascript">

    function completedAjaxRequestCategoeyChauLuc(obj) {

        $('#box-busy').fadeOut('medium', function () {
            $('.black_overlay').css('display', 'none');
        });

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            makeSuccessHighlightChauLuc(" Đã gởi mail thành công");
            window.location.href = returnObj.RedirectUrl;
        } else {
            makeErrorHighlightChauLuc(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightChauLuc(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span><strong>Alert: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $highlight.delay(4000).fadeOut(500);
    }

    function makeSuccessHighlightChauLuc(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong>Success: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area");
        $highlight.delay(4000).fadeOut(500);
    }

    $(document).ready(function () {
        $(".rich-text").cleditor({ width: 520, height: 500, useCSS: true });
        var ids = $("#listHinhThuc").val();
        $("#EmailSendId").val(ids);
    });

    function onlistHinhThuc() {
        var ids = $("#listHinhThuc").val();
        $("#EmailSendId").val(ids);
    }

</script>

@using (Ajax.BeginForm("SendMailTuVan", "Quantri", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div class="section-header">
        <div class="options">
            <button type="submit" name="save" value="save" class="t-button">
                Gởi Email</button>
        </div>
    </div>
    <div id="tabasAddCategory">
        <ul>
            <li><a href="#tabs-1">Thông tin</a></li>
        </ul>
        <div id="tabs-1">
            <table>
                <tr>
                    <td colspan="2">
                        <div class="warning-area">
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Họ Tên :
                    </td>
                    <td class="adminData">
                       @Model.VisaInfo.HoTen
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Email :
                    </td>
                    <td class="adminData">
                       @Model.VisaInfo.Email
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Đt :
                    </td>
                    <td class="adminData">
                       @Model.VisaInfo.Dt
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                       Tư vấn đến nước :
                    </td>
                    <td class="adminData">
                       @Model.VisaInfo.visadencacnuoc
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Nội dung tư vấn :
                    </td>
                    <td class="adminData">
                       @Html.Raw(Model.VisaInfo.NoiDung)
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Chọn email trả lời:
                    </td>
                    <td class="adminData">
                       @Html.HiddenFor(model => model.EmailSendId, new { id = "EmailSendId" })
                       @Html.HiddenFor(model => model.VisaInfo.Type)
                        @Html.HiddenFor(model => model.VisaInfo.Id)
                        @Html.HiddenFor(model => model.VisaInfo.Email)
                       @Html.DropDownList("listEmaiil", null, new { @class = "DropDownListPostNews", @id = "listHinhThuc", @onchange = "onlistHinhThuc()" })
                    </td>
                </tr>
                 <tr>
                    <td class="adminTitle">
                        Tiêu đề email:
                    </td>
                    <td class="adminData">
                      @Html.TextBoxFor(model => model.Tieude, new { @style = "width:300px"})
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                        Bcc:
                    </td>
                    <td class="adminData">
                      @Html.TextBoxFor(model => model.bcc, new { @style = "width:300px"})
                    </td>
                </tr>
                <tr>
                    <td class="adminTitle">
                       Nội dung email:
                    </td>
                    <td class="adminData">
                      @Html.TextAreaFor(model => model.Noidung, new { name = "NoiDung", @class = "txt_NoiDung rich-text validate[required]", style = "width: 98%; height:148px;" })
                    </td>
                </tr>
            </table>
        </div>
    </div>
}
